package site.yunnong.atvris.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.yunnong.atvris.dao.common.api.CommonResult;
import site.yunnong.atvris.dao.common.api.YunnongHttpStatus;
import site.yunnong.atvris.dao.portal.service.StarService;

/**
 * @author JinghaoZhang
 * @date 2021年-04月-07日
 */
@Api(tags = "StarManageController", description = "收藏管理")
@RestController
@RequestMapping("/star")
public class StarManageController {

    @Autowired
    private StarService starService;

    @ApiOperation("添加收藏")
    @PostMapping
    public CommonResult add(Long vid) {
        // todo 现在只能收藏视频
        // vid 是被关注视频的id
        starService.add(vid);
        return CommonResult.result(YunnongHttpStatus.NO_CONTENT);
    }

    @ApiOperation("取消收藏")
    @DeleteMapping
    public CommonResult delete(Long tid) {
        // uid 是被关注者的id
        starService.delete(tid);
        return CommonResult.result(YunnongHttpStatus.NO_CONTENT);
    }

//    @ApiOperation("分页获取用户自身收藏列表")
//    @GetMapping("/list")
//    public CommonResult list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
//                             @RequestParam(value = "pageSize", defaultValue = "6") Integer pageSize) {
//        List<Star> starList = starService.list(pageNum, pageSize);
//        if (CollectionUtils.isEmpty(starList)){
//            // 没有
//            return CommonResult.result(YunnongHttpStatus.NO_CONTENT);
//        }
//        return CommonResult.result(CommonPage.restPage(starList), YunnongHttpStatus.SUCCESS);
//    }

//    @ApiOperation("分页获取其他用户收藏列表")
//    @GetMapping("/list/other")
//    public CommonResult list(@RequestParam("uid") Long userId,
//                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
//                             @RequestParam(value = "pageSize", defaultValue = "6") Integer pageSize) {
//        List<Star> starList = starService.list(userId, pageNum, pageSize);
//        if (CollectionUtils.isEmpty(starList)){
//            // 没有
//            return CommonResult.result(YunnongHttpStatus.NO_CONTENT);
//        }
//        return CommonResult.result(CommonPage.restPage(starList), YunnongHttpStatus.SUCCESS);
//    }
}
